<template>
  <Row>
    <Col :span="2" align="center" style="font-size: 16px"> 查询条件 </Col>
    <Col :span="3" style="margin-right: 15px"> <Input v-model:value="state.searchData.originalSerial" allowClear placeholder="样本编号" /> </Col>
    <Col :span="3" style="margin-right: 15px"> <Input v-model:value="state.searchData.name" allowClear placeholder="样本名称" /> </Col>
    <Col :span="3" style="margin-right: 15px"> <Input v-model:value="state.searchData.extDataList" allowClear placeholder="样本类型" /> </Col>
    <Col :span="3" style="margin-right: 15px"> <Input v-model:value="state.searchData.serialLike" allowClear placeholder="数字编号" /> </Col>
    <Col :span="3" style="margin-right: 15px"> <a-input-number style="width: 100%" v-model:value="state.searchData.capacity" allowClear placeholder="容量" /> </Col>
  </Row>
  <Row style="margin-top: 10px">
    <Col :span="2" />
    <Col :span="3" style="margin-right: 15px"> <Select style="width: 100%" v-model:value="state.searchData.projectId" allowClear :options="state.projectNameList" placeholder="课题组" /> </Col>
    <Col :span="3" style="margin-right: 15px">
      <RangePicker style="width: 100%" v-model:value="state.searchData.sampleTimeEqual" :placeholder="['采样日期', '采样日期']" value-format="YYYY-MM-DD" />
    </Col>
    <Col :span="3" style="margin-right: 15px"> <Input v-model:value="state.searchData.sampleAddress" allowClear placeholder="采样地点" /> </Col>
    <Col :span="3" style="margin-right: 15px"> <Input v-model:value="state.searchData.preservUserName" allowClear placeholder="负责人" /> </Col>
    <Col :span="3" style="margin-right: 15px"> <Input v-model:value="state.searchData.j" allowClear placeholder="患者" /> </Col>
    <Col :span="3" style="margin-left: 15px"> <Button type="blue-white" @click="searchBtnClickFn">查询</Button> </Col>
  </Row>
</template>

<script setup lang="ts">
import Button from '@/framework/components/basic/button/button.vue';
import { Row, Col, Input, Select, RangePicker } from 'ant-design-vue';
import { reactive } from 'vue';
import { taskSearch } from '@/api/base/task-data';

export type SearchState = {
  projectNameList: any[];
  searchData: {
    serial?: string | '样本编号';
    name?: string | '样本名称';
    c?: string | '样本类型';
    epcLike?: string | '数字编号';
    e?: string | '容量';
    projectId?: string | '课题组';
    sampleTimeEqual?: any[];
    sampleAddress?: string | '采样地点';
    preservUserName?: string | '负责人';
    j?: string | '患者';
  };
};
const emits = defineEmits<{
  (e: 'search', data: SearchState['searchData']): void;
}>();
const state: SearchState = reactive({
  searchData: {} as SearchState['searchData'],
  projectNameList: [],
});
const searchBtnClickFn = () => {
  emits('search', state.searchData);
};
const getProjectNameListFn = async () => {
  let params = {
    pageSize: 100000,
    pageNum: 1,
    orderBy: [
      {
        field: 'createTime',
        order: 'desc',
      },
    ],
  };
  const res = await taskSearch(params);
  state.projectNameList = res.result.data.map((item) => ({
    label: item.name,
    value: item.id,
  }));
};
getProjectNameListFn();
</script>

<style scoped lang="less"></style>
